<?php
/**
 * Created by PhpStorm.
 * User: hisheng
 * Date: 2017/6/5
 * Time: 18:15
 */
namespace App\Dao;
use App\Http\Controllers\Controller;
use App\Loan;

class SearchDao extends Controller
{
//    public $job;
//    public $amount;
//    public $sort;
    public $loan;
    public function __construct(Loan $loan)
    {
        $this->loan = $loan ;
    }
    
    public function search($job,$amount,$sort,$day){
        $result = $this->loan
//            ->where('min_amount','<=',$amount)
//            ->where('max_amount','>=',$amount)
            ->where('job','like','%'.$job.'%')
            ->where('is_delete',0)
            ->orderBy($sort,'desc');
//        if($day){
//            $result->where('min_days','<=',$day);
//            $result->where('max_days','>=',$day);
//        }
        $results = $result->paginate(10);
        
        if($results){
            $res = $results->toArray();
            $res['data'] = $this->originIcon($res['data']);
            return $res;
        }
        return [];
        
    }
}